<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
    <head>
        <title>page & pageContext</title>
        <style>
            .wrapper {
                border: 1px solid blue;
                margin: 15px auto;
            }
        </style>
    </head>
    <body>

        <div class="wrapper">
            <p>
                page: <%= page %>
            </p>
            <b>page</b>对象是最没用的一个内置对象。
            <br>
            想开点，不要使用<b>page</b>！
            <br>
            用它还不如使用<b>this</b>，好歹<b>this</b>也表示当前的servlet实例。
        </div>

        <div class="wrapper">
            <p>
                pageContext: <%= pageContext %>
            </p>
            <hr>
            <%-- 为pageContext设置属性 --%>
            <% pageContext.setAttribute( "name", "未央区" ); %>
            <p>
                <%-- 从pageContext中获取指定名称的属性值 --%>
                name: <%= pageContext.getAttribute( "name" ) %>
            </p>
            <%-- 从pageCotnext中删除指定名称的属性--%>
            <% pageContext.removeAttribute( "name" ); %>
            <p>
                <%-- 从pageContext中获取指定名称的属性值 --%>
                name: <%= pageContext.getAttribute( "name" ) %>
            </p>
            <hr>
            <%
                // pageContext.setAttribute( "name", "未央区" );
                pageContext.setAttribute("name", "未央区",PageContext.PAGE_SCOPE );
                // request.setAttribute( "name", "西安市" );
                pageContext.setAttribute( "name", "西安市", PageContext.REQUEST_SCOPE );
                // session.setAttribute( "name", "陕西省" );
                pageContext.setAttribute( "name", "陕西省", PageContext.SESSION_SCOPE );
                // application.setAttribute( "name", "大中国" );
                pageContext.setAttribute( "name", "大中国", PageContext.APPLICATION_SCOPE );
            %>
            <p>
                name(page scope): <%= pageContext.getAttribute( "name", PageContext.PAGE_SCOPE ) %>
            </p>
            <p>
                name(request scope): <%= pageContext.getAttribute( "name", PageContext.REQUEST_SCOPE  ) %>
            </p>
            <p>
                name(session scope): <%= pageContext.getAttribute( "name", PageContext.SESSION_SCOPE  ) %>
            </p>
            <p>
                name(application scope): <%= pageContext.getAttribute( "name", PageContext.APPLICATION_SCOPE  ) %>
            </p>
            <hr>
            <p>
                find : <%= pageContext.findAttribute( "name" ) %>
            </p>
            <hr>
            <p>find name: ${ name }</p>
            <p>name(page scope): ${ pageScope.name }</p>
            <p>name(request scope): ${ requestScope.name }</p>
            <p>name(session scope): ${ sessionScope.name }</p>
            <p>name(application scope): ${ applicationScope.name }</p>
        </div>

        <div class="wrapper">
            <h3>包含其它JSP</h3>
            <jsp:include page="/implicit/inner.jsp"></jsp:include>
        </div>

    </body>
</html>
